<html>
   <head>
      <link rel="stylesheet" type="text/css" href="streema.css" />
      <script type="text/javascript" src="ext/sprintf.js"></script>
      <script type="text/javascript" src="config.js"></script>
      <!-- Google analytics -->
      <script type="text/javascript">
         var _gaq = _gaq || [];
         if ( !streema.config['analytics.account'] ) {
            throw new Error('Invalid Google Analytics account. Check your preferences' );
         }
         _gaq.push(['_setAccount', streema.config['analytics.account']]);
         _gaq.push(['_trackPageview']);

         (function() {
            var ga = document.createElement('script'); 
            ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 
               'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; 
            s.parentNode.insertBefore(ga, s);
         })();
      </script>
      <script>
         load_config = function () {
            var checkbox = function (config,name) {
              this.checked = config[name]
              this.addEventListener('change', function (ev) {
                  config[name] = this.checked;
                  streema.saveConfig()
              }, false)
            }

            var text = function (config, name) {
               this.value = config[name]
               this.addEventListener('change', function (ev) {
                  var value = parseInt(this.value);
                  if (isNaN(value)) {
                     this.value = config[name]
                     return
                  }
                  config[name] = value
                  this.value = config[name]
                  streema.saveConfig()
              }, true)
            }

            var type_handlers = {'checkbox': checkbox, 'text': text}
            var option;
            for ( option in streema.config ) {
               var elem = document.getElementsByName(option);
               elem = elem[0]
               if (elem && elem.type in type_handlers) {
                  type_handlers[elem.type].call(elem, streema.config, option)
               }
            }
         }
      </script>
   </head>
   <body class="options" onload="load_config()">
      <h1>Under the hood</h1>
      <h2>Desktop Notifications</h2>
      <p><a href="http://code.google.com/chrome/extensions/notifications.html" target="_blank">Desktop notifications</a> notify users that something has happened. Notifications appear outside the browser window.</p>
      <input name="notifications.enable" type="checkbox" /><label for="notifications.enable"> Enable Desktop Notifications</label>
      <br />
      <label for="notifications.timeout">How many time they must remain shown? (millisecs) </label><input name="notifications.timeout" type="text" />
   </body>
</html>

